<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      class Animal {
        name = "";
        age = 0;

        constructor(name, age) {
          this.name = name;
          this.age = age;
        }

        eat(food) {
          console.log(`${this.name} 吃 ${food}`);
        }
      }

      class Dog extends Animal {
        money = 0;

        constructor(name, age, money) {
          // 如果子类继承了父类，那么我们必须在子类构造器的第一句执行 super
          super(name, age);

          this.money = money;
        }

        eat(food, place) {
          console.log(`${this.name} 在 ${place} 里面吃`);
        }
      }
      const d1 = new Dog("冈瑟四世", 5, 2500000000);
      //   d1.money = 25000000000;
      d1.eat("牛排", "豪宅");
      console.log(d1);
    </script>
  </body>
</html>
